Binary search pipeline

ABSTRACT

Efficient hardware implementations of a binary search algorithm are provided.

RELATED APPLICATION DATA

The present application claims priority under 35 U.S.C. 119(e) to U.S.Provisional Patent Application No. 61/409,380 for BINARY SEARCH PIPELINEfiled on Nov. 2, 2010 (Attorney Docket No. FULCP023P), the entiredisclosure of which is incorporated herein by reference for allpurposes.

BACKGROUND OF THE INVENTION

The present invention relates to efficient hardware implementations of abinary search algorithm.

The term “binary search” refers to an algorithm for locating theposition of an element in a sorted list. Initially, the algorithmcompares the middle element of the sorted list to a key value. If thatelement is equal to the key, then the position has been found.Otherwise, the upper half or lower half of the list is chosen forfurther searching based on whether the key is greater than or less thanthe middle element. This continues iteratively until either the positionis found, or the key is determined not to be in the list. Each iterationof the binary search algorithm reduces the number of elements needed tobe checked by a factor of two, finding the key (if it exists in thelist), or determining that the key is not present, in logarithmic time.This is to be contrasted with linear search in which the key is comparedto each element in an unsorted list sequentially until the position isfound.

SUMMARY OF THE INVENTION

According to the present invention, efficient hardware implementationsof a binary search algorithm are provided. According to various specificembodiments, a circuit is provided that is configured to perform asearch for a key in a sorted list of entries using a plurality of binarysearch iterations. The circuit includes plurality of binary searchpipeline stages configured in a pipeline. Each pipeline stage includesmemory storing an orthogonal subset of the entries relative to thesubsets of the entries in the memories of all others of the pipelinestages. The memory in each successive pipeline stage has exponentiallymore storage capacity (each stage having twice the memory of thepreceding stage) and includes entries corresponding to a particular oneof the binary search iterations. Comparison circuitry is provided thatis configured to compare the key to a particular entry stored in thememory of the pipeline stage, generate a comparison result, and pass thekey and the comparison result to the immediately subsequent pipelinestage. The comparison result indicates whether the key is greater thanor equal to, or less than the particular entry to which the key wascompared. The comparison circuitry also selects the index for the nextstage's lookup.

According to a specific embodiment, the circuit further includes aparallel comparison stage preceding an initial one of the pipelinestages. The parallel comparison stage includes N registers each storingone of the entries, and parallel comparison circuitry configured tocompare the key to each of the entries in the N registers in parallel,generate a parallel comparison result, and pass the key and the parallelcomparison result to the initial pipeline stage. The initial pipelinestage is configured to use the parallel comparison result to select theparticular entry in the memory of the initial pipeline stage to whichthe key is compared. The parallel comparison stage corresponds to thefirst log₂ N of the binary search iterations.

According to another specific embodiment, the memory in each pipelinestage is configured in a plurality of slices, each slice including aunique subset of the entries in the memory. According to an even morespecific embodiment, the comparison circuitry in each pipeline stage isconfigurable to compare different size keys by combining comparisonsbetween slices. According to an even more specific embodiment, eachslice is configured to identify a particular one of a plurality ofactions to perform on a data unit corresponding to the key, and whereinthe circuit is configured to identify multiple actions for keys spanningmultiple slices.

According to another specific embodiment, one or more additional bitsare associated with the key, the circuit further comprising an actiontable comprising a plurality of entries. Each entry in the action tablecorresponds to a particular action to perform on a data unitcorresponding to the key. The one or more additional bits are used as anindex into the action table.

According to another specific embodiment, the entries in the memory ofeach pipeline stage correspond to two consecutive binary searchiterations, and the circuit further includes speculative comparisoncircuitry associated with each pipeline stage configured to compare thekey to each of two entries associated with the second one of the binarysearch iterations that correspond to the particular entry, generatespeculative comparison results corresponding to the two entries. Thecomparison circuitry in each memory stage is also configured to selectone of the speculative comparison results based on the comparison resultreceived from the immediately preceding memory stage.

According to various other specific embodiments, the comparisoncircuitry in each of the pipeline stages is alternatively configurableto perform a prefix match comparison, an exact match comparison, or arange table comparison.

A further understanding of the nature and advantages of the presentinvention may be realized by reference to the remaining portions of thespecification and the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a binary search pipelineaccording to various embodiments of the invention.

FIG. 2 is a more detailed block diagram illustrating a binary searchpipeline according to various embodiments of the invention.

FIGS. 3-6 are block diagrams illustrating optimizations of a binarysearch pipeline according to various embodiments of the invention.

DETAILED DESCRIPTION OF SPECIFIC EMBODIMENTS

Reference will now be made in detail to specific embodiments of theinvention including the best modes contemplated by the inventors forcarrying out the invention. Examples of these specific embodiments areillustrated in the accompanying drawings. While the invention isdescribed in conjunction with these specific embodiments, it will beunderstood that it is not intended to limit the invention to thedescribed embodiments. On the contrary, it is intended to coveralternatives, modifications, and equivalents as may be included withinthe spirit and scope of the invention as defined by the appended claims.In the following description, specific details are set forth in order toprovide a thorough understanding of the present invention. The presentinvention may be practiced without some or all of these specificdetails. In addition, well known features may not have been described indetail to avoid unnecessarily obscuring the invention.

According to various embodiments of the present invention, efficienthardware implementations of a binary search algorithm are provided.Various specific embodiments including a number of optimizations of thebasic design are also described.

An example of a particular embodiment will now be described in thecontext of an array that includes 1024 sorted 32-bit values havingindices in ascending order, i.e., the lowest index in the arraycorresponds to the lowest 32-bit value, and the highest indexcorresponds to the highest 32-bit value. If implemented in C, thealgorithm would look like:

int findIndex(int Key; int k[1024]) {   int i=1024/2, step=1024/2;  while (step>0) {     step=step/2;     if (Key>=k[i]) i+=step;     elsei−=max(1,step);   }   return i; }

According to this embodiment of the present invention, the iterativebinary search algorithm is unrolled into a pipeline in which the valuesk[0 . . . 1023] are distributed through SRAM stages of increasing sizeaccording to the iteration in which they are needed. That is, forexample, and as illustrated in FIG. 1, k[512] is stored in the 1^(st)stage, k[256] and k[768] are stored in the 2^(nd) stage, k[128], k[384],k[640], and k[896] are stored in the 3^(rd) stage, etc. This results ina pipeline of SRAM stages of exponentially increasing size.

At each stage, a comparison is made between the key value for which thesearch is being conducted, and the relevant one of the stored values inthat stage. In the first stage, the key is compared to k[512], i.e., thevalue stored at index 512. Because the values are stored in sorted,ascending order, if the key is greater than or equal to k[512], the key(if it is in the array) is stored at index 512 or above. If, on theother hand, the key is less than k[512], the key (if it is in the array)is stored at an index below 512. Depending on the result of this firstcomparison, the key is then compared to the appropriate one of the twovalues stored in the 2^(nd) stage, i.e., either k[768] or k[256].

Stated more generally, the comparison chooses between >= or <. In earlystages, the branching goes to i′=i+step for K>=k[i] or i′=i−step forK<k[i]. At the very last stage, the branching goes to index i′=i forK>=k[i] or i′=i−1 for K<k[i]. Note that this last stage has anasymmetric step of 0 for >= or −1 for <, but this ends up finding theright i such that k[i]<=K<K[i+1], i.e., the desired final state of thealgorithm

That is, once half of the array has been eliminated, the index that ishalfway between the upper and lower bounds of the remaining half of thearray is chosen for the next comparison. This process is iterated,resulting in ever tighter upper and lower bounds on the range ofpossible indices, until the last index in the final stage is reached(i.e., the upper and lower bounds are equal), and it is then determinedthat either the value stored at this final index is the value beingsearched for (i.e., the key), or the key value is not stored in thearray. This embodiment requires log₂ (N) stages which, in this example,is 10.

As should now be clear, the possible set of values for comparison to thekey in each successive iteration are orthogonal sets, e.g., k[512] willonly be compared to the key once. Thus, instead of iterating on the samearray (which would present a significant bandwidth bottleneck), theorthogonal sets of array values are stored in successively larger SRAMsarranged in series. The result of each stage's comparison is then usedto identify the index for the next iteration.

According to one class of embodiments, each of the stages of the binarysearch circuit is implemented in SRAM, with each successive stagestoring twice as many entries as the last. In the example of 1024 32-bitvalues, the first stage has a single 32-bit entry, the second stage hastwo 32-bit entries, the third has 4, the fourth 8, the fifth 16, and soon, until the 10^(th) stage which has 512 entries. Thus, in thisexample, 10 lookups are performed in 10 different SRAMs, as opposed tothe conventional algorithmic approach in which 10 lookups would beperformed sequentially on the same SRAM.

It is worth noting that, according to a specific embodiment, when thenumber of entries in the successive stages is added up, the total comesto 2^(N)−1, or in this example, 1023. The “missing” entry corresponds tothe index 0. According to this implementation, if the result of thelookup is this index, then that means that the key being searched for isless than every value in the array, and the result is therefore treatedas a “miss.”

According to various specific embodiments of the invention,optimizations are provided which take advantage of the basic binarysearch pipeline described above to enable some powerful functionalities.Various embodiments will be described with reference to 16K-entry SRAMs(rather than the 1024 entries in the example above).

Optimization 1—16-Way Parallel Root Comparison

According to a particular class of embodiments, a parallel comparison isprovided at the front end of the pipeline to save both latency and area.That is, small SRAMs (e.g., 1-entry, two-entry, etc.) are notarea-efficient in that they have a large amount of overhead relative tothe actual storage capacity. Therefore, instead of SRAM stages toimplement the first few stages of the binary search circuit pipeline,specific embodiments of the invention employ discrete registers that areread and compared in parallel rather than in series.

According to a particular implementation illustrated in FIG. 2, 16 suchregisters 202 are provided to implement a 16-way parallel comparisonthat takes the place of the first four stages of the 10-stage pipelinedescribed above. The successive stages of the pipeline are thenimplemented in SRAM beginning with a 16-entry SRAM 204 followed by a32-entry SRAM 206, and so on. This parallel comparison effectively“discovers” the first 4 bits of the final index in a faster and morearea efficient manner, with each successive bit (i.e., bits 5-10) beingdiscovered by the successive SRAM stages.

The use of discrete logic to implement the parallel comparison at theroot of the binary search pipeline enables a more powerful functionalitythan would be feasible if all of the stages of the pipeline wereimplemented in SRAM.

According to a specific embodiment, the result of the 16-way comparisonis treated as a 4-bit partition number that maps to one of sixteen1023-entry partitions. That is, the four bits “discovered” by the 16-waycomparison are used as in index into a 16-entry by 4-bit SRAM toretrieve another 4-bit value which maps to the partition in which thebinary search is to proceed. The remaining stages of the binary searchto discover 10 additional bits in the selected partition. Thus, the endresult of the lookup in this embodiment is actually a 14-bit value,i.e., 4 bits of partition and 10 bits of index. As will be understood,the successive stages of each partition may all be implemented as partof the same SRAM. That is, the first SRAM stage following the 16-waydiscrete logic comparison is a 16-entry SRAM with 16 partitions having 1entries each.

Partitions means you can split the table into multiple tables that canbe used orthogonally, or used exclusively, i.e., you can only use tablesrepresented by particular partitions. One nice feature of partitions isthat, while you have to maintain sorting within a partition, you don'tnecessarily need to do so as between partitions.

Partitions may also support an efficient way of adding sorted entries.That is, one very useful functionality that is enabled by this approachis the ability to swap partitions in and out of a lookup resource whilethe system of which the resource is a part is operating, i.e., a “hotswap.” For example, in the context of IP routing, implementing a routingtable with this binary search circuit would enable the routing table tobe updated on the fly.

According to a particular embodiment, one or more of the partitions canbe treated as a “scratch” partition to which new values can be added atarbitrary times. Once all of the desired values are added, the scratchpartition can then be swapped for one of the other partitions in asingle operation, e.g., in one cycle. Such a functionality could beused, for example, in the context of IP routing to add several hundredentries to a routing table while traffic is flowing through the system.

Optimization 2—Speculatively Evaluate 2 Stages in Parallel

According to some embodiments of the invention, following the parallelcomparison, the radix of the binary search is changed. That is, insteadof only one lookup in each iteration, multiple lookups are performedsimultaneously. For example, instead of 2-way branching based on eachiteration (as shown in FIG. 3A), four-way branching may be used, e.g.,three lookups spanning two neighboring stages of the algorithm may beperformed to reduce latency (as shown in FIG. 3B). That is, one lookupfor the current stage (SRAM 302), and both possibilities (SRAMs 304 and306) for the following stage. Based on the result of the first stage youthen pick (logic 308) the appropriate one of the two results from thesecond stage. Thus, three lookups are speculatively performedsimultaneously instead of two sequentially, effectively cutting thelatency in half, i.e., two iterations done in the time of a singleiteration. However, the increase in the number of lookups results in anincrease in power dissipation (i.e., attributable to the unused lookupresult). As will be understood, there is a balance to be struck betweenadditional power dissipation and reduction in latency which may bedifferent for different applications. According to a particularimplementation, four-way branching is selected. However, it should beunderstood that a different radix might apply for a given application.

Because we are free to pick the search radix, the stage of the binarysearch circuit following the 16-way parallel comparison is three16-entry SRAMs which are small, but sufficiently large to be doneefficiently using SRAM. Each successive stage then grows by 4× (i.e.,three 64-entry SRAMs, three 256-entry SRAMs, etc.) rather than 2×.

Optimization 3—Cascade Keys

In some embodiments, the keys are 32-bit keys. However, in someapplications, the keys being looked up may be wider and/or there may bekeys of different widths that are processed by the same circuitry.Therefore, according to a specific embodiment of the invention, four32-bit key binary search pipelines are implemented in parallel and in away which enables these four “slices” to be configured and used in ahighly flexible manner. For example, the four slices may be configuredas a single large lookup that includes 4 times the entries of a singlepipeline.

Alternatively, slices can be cascaded to look up 64, 96, or 128-bitkeys, i.e., combining 2, 3, or 4 slices, respectively. Each of thecascaded slices makes an independent 32-bit comparison, the results ofwhich are then “combined” to determine the cascaded result for the nextstage, and the result is broadcast to next stage for each of the slices.So, for example, if the key being looked up is a 64-bit key, and theresult of the more significant 32-bit slice lookup is “greater than”then this is the result of the lookup. On the other hand, if the resultof the more significant lookup is “equal to,” then the result from theless significant 32-bit slice lookup is used.

FIG. 4 illustrates the cascading of 3 such slices according to aspecific implementation. SRAMs 402, 404, and 406 may be configured to bepart of independent parallel pipelines. However, by setting input bitsSC (start cascade) and EC (end cascade), cascade logic 408, 410, and 412are configured to combine the comparisons across the member slices ofthe cascade. As shown, cascade logic 408 has SC=1 and EC=1, cascadelogic 410 has SC=1 and EC=0, while cascade logic 412 has SC=0 and EC=1.This configuration uses single width keys in the slice including SRAM406, while combining two slices to use double-width keys in the sliceincluding SRAMs 404 and 402. To minimize the latency, the circuit wasdesign to ripple a most-significant-prefix (MSP) comparison from themost-significant slice to least-significant slice, and in parallel,ripple a least-significant-prefix (LSP) comparsion in the oppositedirection. Thus each slice collects information from the slices aboveand below it in the cascade, and all slices produce consistentcomparison results. The CMP, MSP, and LSP channels encode 3 cases (lessthan, equal to, and greater than) because this is necessary to computethe final >=comparison. The logic for this compare can be designed withstandard techniques.

In the context of IP routing, this architecture allows for IPv4 (32-bitlookups) and IPv6 (128-bit lookups) routing to be done simultaneouslyusing the same hardware. In addition, Ethernet (which uses 60-bit keys)can be done with this architecture.

According to some embodiments implemented in the context of packetswitching, one or more “scenario” bits identifies the type of packetbeing processed and therefore the type of lookup that needs to beperformed, i.e., which partition to select. In addition, 4 bits of TCAMresource are added to enable programmable selection of a partitiondepending on packet characteristics. This enables efficientimplementation of virtual routers in which many different routing tablesneed to be maintained.

Optimization 4—Prefix Match

According to some implementations, the same hardware is configurable tosupport both “exact match” and “prefix match” searches. Exact matchsearch is important, for example, in the context of IP routing foridentifying the specific machine to which a packet is addressed, i.e.,the destination IP address. Prefix match search is like exact match(i.e., exact match is a special case of prefix match) except that itignores some number of the least significant bits. Again referring tothe context of IP routing for an example, many routing algorithms onlyneed to look at the top 24 bits of a 32-bit value to make certaindecisions.

According to a specific class of implementations, in addition todetermining whether the key is greater than, less than, or equal to thekey, the prefix match “length” is also determined by determining howmany of the least significant bits do NOT match the key. So, forexample, if an exact match is found, this number is “0.” As shown inFIG. 5, the prefix match length is tracked through each successive stageof the binary search pipeline through a channel that propagates thenumber of bits that match for the closest entry encountered so far. Eachstage combines a >=compare with the LPM compare, and if the newcomparison result is >=, also replaces the rippling PM field. Whateverthe PM field is at the end of the pipeline is compared against a fieldof the action SRAM to determine if the lookup key satisified the prefixmatch. So, for example, there might be a requirement that a specificaction be taken or a particular rule is only valid if the key is withinsome range defined by the prefix match, e.g., a rule is valid where thekey is within 2^(n) of the target key. Or, put another way, you wouldhave an n-bit range that would all map to the same result.

According to another class of embodiments, a binary search pipelineconstructed in accordance with the invention may be configured toimplement another special case of prefix match, i.e., a range table. Arange table is not concerned with the upper bound, but instead whetherthe key is greater than or equal to a particular entry and less than thenext entry, i.e., all numbers x greater than or equal to a AND less thanb go into the same bin. This can be accomplished by disabling the prefixmatch comparison. A range table can be used by IP routing algorithms,for example, to identify TCP/UDP port numbers, e.g., ports 255-259belong to a particular protocol.

According to a particular class of embodiments, this configurability isimplemented in the comparison circuit which does both a 3-way compare,and a prefix length compare. Any time the result is “greater than orequal to,” the index is updated, and the best prefix match so far issaved. Thus, when the end of the pipeline is reached, the final index aswell as the number of bits matched may be identified.

From the foregoing, it will be appreciated that the binary searchpipeline can be configured rule-by-rule. That is, every entry in thepipeline can be either an exact match, a prefix match, or “from here onto the next entry,” i.e., a range match.

There is also a representation of a “NO OP.” A range table is somewhatgeneric in that every key maps to some range, although some of theranges represent a miss; which is different from not finding anything,i.e., the key was found, it just didn't lead to an action.

The current design costs some extra area in that it requires area forthe comparators, e.g., a two-bit comparison result and a 5-bit prefixmatch count; the prefix match circuit being more complicated than a3-way compare. For example, if there are 15 stages of comparison in theSRAM section that each require a prefix compare, and then there are 4slices to get out to 128-bit keys, so there are actually 60 comparators.

Thus, the hardware can do all three modes, i.e., exact match, prefixmatch, and range match, all mixed up in any way you like.

Optimization 5—Additional Conditions

According to some embodiments, the discrete logic at the root of thebinary search circuit (e.g., as shown in FIG. 2) is combined with theuse of wider keys in the parallel lookup portion of the circuit toenable the encoding and application of additional conditions relating toprocessing of the key. For example, as shown in FIG. 6, a 36-bit keycould be used in which the bottom 32 bits correspond to the numeric keyvalue being searched, while the top four bits are used to identifyconditions that enable each partition (e.g., in TCAM 602) for handlingthe key or some other value or unit to which the key corresponds, e.g.,if the highest order bit is set, then the key is invalid, or when aspecific pattern of bits is set, a particular set of processing rulesapplies. Because the root is not that big, advantageous features withsuch additional conditions may be added without adding significantoverhead to the overall circuit. One preferred implementation is 4 extrabits of key and 8 extra configuration bits. The 8 bits are used like aTCAM, and encode for each of the top 4 bits of the key, if it must be 0,must be 1, don't care in order for the partition to be valid.

In the context of IP routing, these condition bits might, for example,identify the type of packet being processed (e.g., IPv4 or IPv6), theport on which a packet was received, type of frame (unicast vs.multicast), routing context, virtual router table number, scratchpartition, etc. And depending on these conditions, specific partitionsof the binary search circuit may be selected. For example, ¼ of thepartitions might be dedicated to IPv4 routing while ¾ might be dedicatedto IPv6 routing. Alternatively, half could be used for IP multicast, andthe other half for IP unicast. Thus, the same hardware resources may beused for different purposes. A wide variety of other possibilities forusing such extra condition bits will be appreciated by those of skill inthe art.

According to a particular implementation, in addition to the prefixmatch comparison, additional information is provided that map to a widevariety of action options. That is, the binary search pipeline“remembers” the prefix match and provides a 14-bit index into a 16Kentry Action SRAM, from which (assuming a “hit” based on the prefixmatch comparison) a 50-bit value is retrieved; 8 bits representing theprefix length, and 42-bits being a number of fields representing theactions to be taken. Such action options might include, for example,routing options, dropping, counting, policing, rate throttling, changingframe priority, changing frame VLANs, route frames, switch frames, sendframes to a processor, etc. If a sufficient number of bits of the key donot match, i.e., the prefix match comparison is negative, some defaultbehavior is selected, e.g., send the packet to a default router, dropthe packet, etc.

In the context of frame processing pipelines in packet switches, theconventional approach to achieve this kind of functionality andconfigurability is to use off-chip TCAMs which are immensely powerhungry and represent significant additional cost, e.g., hundreds ofdollars extra. In addition, such off-chip TCAMs don't provide the actiontable, i.e., they only provide the index into a separate table. Bycontrast, a binary search pipeline implemented according to specificembodiments of the invention uses considerably less power than a TCAM,is low latency, and can reside on-chip along with the action tables withas many as a million or more entries in current generations. And thiscan be done in comparable area to that generally taken up by the I/Ocircuitry necessary for communicating with the off-chip TCAM. Comparedto on-chip TCAM's, the area cost of a large BSP approaches ¼, while thepower can be 1/10.

And as described above, some implementations of the binary searchpipeline have 4 “slices” of 16K entries each, each of which can performone “action.” So, for 32-bit lookups, 4 different actions could beperformed; for 64-bit lookups, 2 different actions could be performedfor the same rule; and for 128-bit lookups, up to four actions could beperformed for the same rule. And these different scenarios could occurusing the same hardware on consecutive lookups.

The binary search pipeline is almost as functional as a TCAM, with theexception that it can't mask out higher order bits. That is, TCAM is amasked compare in which bits are masked and a compare for exact match isperformed. The binary search pipeline is an ordered compare, and then wecan add some number of bits on the top (e.g., four) that do a maskedcompare (e.g., the 16-way parallel compare described above). Thus, abinary search pipeline could be used to do an IP lookup, a multicastlookup, an ACL, etc. It can perform the same function in a frameprocessing pipeline as a TCAM, with the advantage that it isconsiderably more area and power efficient.

The binary search pipeline and TCAM can work very well together. Forexample, adding entries to a binary search pipeline is typically acumbersome process involving sorting within a scratch partition, copyingof the scratch partition in, and then possibly sorting the partitions.This takes considerable time and processing resources. On the otherhand, if the binary search pipeline is combined with a TCAM, entries canbe added to the TCAM quickly and the change can take effect right away.This can be done until there are a sufficient number of new entries tobe added to the binary search pipeline as a batch. Effectively, the TCAMacts as a temporary cache for modified entries.

According to various embodiments of the invention, the separationbetween how the compares are done versus how the keys are stored takesadvantage of the decreasing size of SRAM over time. That is, with suchembodiments, most of the area is in the storage of the keys. The SRAMskeep getting larger as you progress down the pipeline (e.g., by factorsof 4), but the area attributable to comparisons stay the same. Thus, fora small binary search pipeline, the area may be dominated by comparisoncircuitry. However, as the binary search pipeline gets larger, thepercentage of area attributable to SRAM grows (e.g., for 64 k, SRAMconsumes about 60-70%). Given improvements in SRAM area over time, thebinary search pipeline is only going to get better in terms of area. Bycontrast, for TCAMs, the area overhead is linearly proportional.

Embodiments of the present invention are particularly useful forapplications in which the values in the array can be sorted in advance,and in which the values in the array don't change much relative to thenumber of lookups performed. For example, IP packet routing employsrouting tables which are typically modified every minute or two ascompared to the hundreds of millions (or even billions) of times persecond lookups are performed. Thus, the computational cost of sortingthe list every time it is updated is well worth it when one considersthe latency and power savings that such an approach represents ascompared to more conventional approaches such as, for example,content-addressable memories which employ a power hungry, brute forceapproach.

It will be understood that the functionalities described herein may beimplemented in a wide variety of contexts using a wide variety oftechnologies without departing from the scope of the invention. That is,embodiments of the invention may be implemented in processes andcircuits which, in turn, may be represented (without limitation) insoftware (object code or machine code), in varying stages ofcompilation, as one or more netlists, in a simulation language, in ahardware description language, by a set of semiconductor processingmasks, and as partially or completely realized semiconductor devices.The various alternatives for each of the foregoing as understood bythose of skill in the art are also within the scope of the invention.For example, the various types of computer-readable media, softwarelanguages (e.g., Verilog, VHDL), simulatable representations (e.g.,SPICE netlist), semiconductor processes (e.g., CMOS, GaAs, SiGe, etc.),and device types (e.g., frame switches) suitable for designing andmanufacturing the processes and circuits described herein are within thescope of the invention.

Embodiments of the invention are described herein with reference toswitching devices, and specifically with reference to packet or frameswitching devices. According to such embodiments and as described above,some or all of the functionalities described may be implemented in thehardware of highly-integrated semiconductor devices, e.g., 1-Gigabit and10-Gigabit Ethernet switches, various switch system switches, andsimilar devices.

While the invention has been particularly shown and described withreference to specific embodiments thereof, it will be understood bythose skilled in the art that changes in the form and details of thedisclosed embodiments may be made without departing from the spirit orscope of the invention. In addition, although various advantages,aspects, and objects of the present invention have been discussed hereinwith reference to various embodiments, it will be understood that thescope of the invention should not be limited by reference to suchadvantages, aspects, and objects. Rather, the scope of the inventionshould be determined with reference to the appended claims.

1. A circuit configured to perform a search for a key in a sorted listof entries using a plurality of binary search iterations, comprising aplurality of binary search pipeline stages configured in a pipeline,each pipeline stage comprising: memory storing an orthogonal subset ofthe entries relative to the subsets of the entries in the memories ofall others of the pipeline stages, the memory in each successivepipeline stage having exponentially more storage capacity than animmediately previous pipeline stage and including entries correspondingto a particular one of the binary search iterations; and comparisoncircuitry configured to compare the key to a particular entry stored inthe memory of the pipeline stage, generate a comparison result, and passthe key and the comparison result to the immediately subsequent pipelinestage, the comparison result indicating whether the key is greater thanor equal to, or less than the particular entry to which the key wascompared, the comparison circuitry also being configured to select theparticular entry to which the key is compared with reference to thecomparison result received from the immediately previous pipeline stage.2. The circuit of claim 1 further comprising a parallel comparison stagepreceding an initial one of the pipeline stages, the parallel comparisonstage comprising N registers each storing one of the entries, andparallel comparison circuitry configured to compare the key to each ofthe entries in the N registers in parallel, generate a parallelcomparison result, and pass the key and the parallel comparison resultto the initial pipeline stage, wherein the initial pipeline stage isconfigured to use the parallel comparison result to select theparticular entry in the memory of the initial pipeline stage to whichthe key is compared, and wherein the parallel comparison stagecorresponds to the first log₂ N of the binary search iterations.
 3. Thecircuit of claim 2 wherein the memory in each pipeline stage isconfigured in several parallel slices, each slice including a uniquesubset of the entries in the memory.
 4. The circuit of claim 3 whereinthe comparison circuitry in each pipeline stage is configurable tocompare different size keys by combining comparisons between slices. 5.The circuit of claim 2 wherein one or more additional bits areassociated with the key used by the parallel comparison stage, whereinthe additional bits are used to apply additional conditions relating toprocessing of the key.
 6. The circuit of claim 1 wherein the entries inthe memory of each pipeline stage correspond to two consecutive binarysearch iterations, the circuit further comprising speculative comparisoncircuitry associated with each pipeline stage configured to compare thekey to each of two entries associated with the second one of the binarysearch iterations that correspond to the particular entry, generatespeculative comparison results corresponding to the two entries, thecomparison circuitry in each memory stage also being configured toselect one of the speculative comparison results based on the comparisonresult received from the immediately preceding memory stage.
 7. Thecircuit of claim 1 wherein the comparison circuitry in each of thepipeline stages is alternatively configurable to perform a prefix matchcomparison, an exact match comparison, or a range table comparison. 8.The circuit of claim 1 wherein the memory in each pipeline stage isconfigured in a plurality of slices, each slice including a uniquesubset of the entries in the memory, and wherein the comparisoncircuitry in each pipeline stage is configurable to compare differentsize keys by combining comparisons between slices.
 9. The circuit ofclaim 8 wherein each slice is configured to identify a particular one ofa plurality of actions to perform on a data unit corresponding to thekey, and wherein the circuit is configured to identify multiple ones ofthe actions for keys spanning multiple ones of the slices.
 10. Anintegrated circuit comprising the circuit of claim 1, wherein theintegrated circuit comprises a packet switching device.
 11. Theintegrated circuit of claim 10 wherein the packet switching devicecomprises an Ethernet switch.
 12. At least one computer-readable mediumhaving data structures stored therein representative of the circuit ofclaim
 1. 13. The at least one computer-readable medium of claim 12wherein the data structures comprise a simulatable representation of thecircuit.
 14. The at least one computer-readable medium of claim 13wherein the simulatable representation comprises a netlist.
 15. The atleast one computer-readable medium of claim 12 wherein the datastructures comprise a code description of the circuit.
 16. The at leastone computer-readable medium of claim 15 wherein the code descriptioncorresponds to a hardware description language.
 17. A set ofsemiconductor processing masks representative of at least a portion ofthe circuit claim 1.